package morerecursion;

public class Recursive {

	public static int add(int[] a){
		int result=0;
		int n = a.length;
		for (int i=0; i<n; i++)
			result = result + a[i];
		return result;
	}
	
	public static int radd(int[] a){
		int result = radd( a, a.length);
		return result;
	}
	
	public static int radd(int[] a, int number_left){
		if (number_left == 1)
			return a[0];
		int result = radd(a, number_left - 1);
		return result + a[number_left-1];
	}
	
	
	public static void main( String[] a ){
		final int[] array = {10, 3, -1, 72};
		int result = add( array );
		System.out.println( "Iterative sum of all the elements of the array is " + result);

		result = radd( array );
		System.out.println( "Recursive sum of all the elements of the array is " + result);
	}
}
